﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Tallerista.Domain;
using Tallerista.Domain.Extensions;

namespace Tallerista.Test
{
    [TestFixture]
    public class DateRangeFixture
    {
        DateTime initDate = new DateTime(2005, 01, 01);
        DateTime endDate = new DateTime(2012, 01, 01);
        private DateTime? endDateNulo = null;

        [Test]
        public void Deberia_estar_en_el_rango()
        {
            DateTime middleDate = new DateTime(2008, 01, 01);
            IDateRange myRange = new DateRange(initDate, endDate);

            Assert.AreEqual(true, myRange.Contains(middleDate));
        }

        [Test]
        public void No_Deberia_estar_en_el_rango()
        {

            DateTime middleDate = new DateTime(2014, 01, 01);
            IDateRange myRange = new DateRange(initDate, endDate);

            Assert.AreEqual(false, myRange.Contains(middleDate));
        }

        [Test]
        public void Deberia_estar_en_el_rango_con_end_Nulo()
        {

            DateTime middleDate = DateTime.Now;
            IDateRange myRange = new DateRange(initDate, endDateNulo);

            Assert.AreEqual(true, myRange.Contains(middleDate));
        }

        [Test]
        public void NO_Deberia_estar_en_el_rango_con_end_Nulo()
        {

            DateTime middleDate = new DateTime(2001, 01, 01);
            IDateRange myRange = new DateRange(initDate, endDateNulo);

            Assert.AreEqual(false, myRange.Contains(middleDate));
        }

        [Test]
        public void Deberia_estar_en_el_rango_con_end_Nulo_con_extensions_method()
        {

            DateTime middleDate = new DateTime(2005, 05, 05);
            bool estaDentroDelRango = middleDate.Between(initDate, endDateNulo);

            Assert.AreEqual(true, estaDentroDelRango);
        }

        [Test]
        public void NO_Deberia_estar_en_el_rango_con_end_Nulo_con_extensions_method()
        {
            DateTime middleDate = new DateTime(2000, 05, 05);
            bool estaDentroDelRango = middleDate.Between(initDate, endDateNulo);

            Assert.AreEqual(false, estaDentroDelRango);
        }

        [Test]
        public void El_lapso_de_tiempo_en_años_deberia_ser_0()
        {

            DateTime myInitDate = new DateTime(2005, 01, 01);
            DateTime myEndDate = new DateTime(2005, 02, 01);
            IDateRange myRange = new DateRange(myInitDate, myEndDate);
            
     
            Assert.AreEqual(0, myRange.Duracion);
        }

        [Test]
        public void El_lapso_de_tiempo_en_años_deberia_ser_1()
        {

            DateTime myInitDate = new DateTime(2004, 01, 01);
            DateTime myEndDate = new DateTime(2005, 02, 01);
            IDateRange myRange = new DateRange(myInitDate, myEndDate);


            Assert.AreEqual(1, myRange.Duracion);
        }


        [Test]
        public void Deberia_calcular_lapso_de_tiempo_con_end_nulo()
        {

            DateTime myInitDate = new DateTime(2009, 01, 01);
            DateTime? myEndDate = null;
            IDateRange myRange = new DateRange(myInitDate, myEndDate);


            Assert.AreEqual(2, myRange.Duracion);
        }

    }
}
